package com.atguigu.yygh.sms.listener;

import com.atguigu.yygh.rabbit.constaner.MqConst;
import com.atguigu.yygh.vo.msm.MsmVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author luoyin
 * @Date 18:08 2022/10/10
 **/
@Component
public class RabbitMqListener {

    @RabbitListener(
            bindings = @QueueBinding(exchange = @Exchange(MqConst.EXCHANGE_DIRECT_MSM),
            value = @Queue(MqConst.QUEUE_MSM_ITEM), key = MqConst.ROUTING_MSM_ITEM)
    )
    public void  getSmsMessage(MsmVo msmVo , Message message , Channel channel){
        String phone = msmVo.getPhone();
        System.out.println("给手机号 " + phone + "发送短信!"+msmVo.getParam());
}
}
